package net.sudot.commons.security;

import org.apache.shiro.authc.UsernamePasswordToken;

/**
 * 用户认证令牌
 *
 * @author tangjialin on 2017-06-14 0014.
 */
public class UserAuthenticationToken extends UsernamePasswordToken {

    /** 用户类型 */
    private Class<?> userClass;
    /** 是否需要验证凭证 */
    private boolean isVerifyCredentials = true;

    /**
     * 构造方法
     *
     * @param userClass  用户类型
     * @param username   用户名
     * @param password   密码
     * @param rememberMe 记住我
     * @param host       主机
     */
    public UserAuthenticationToken(Class<?> userClass, String username, String password, boolean rememberMe, String host) {
        super(username, password, rememberMe, host);
        this.userClass = userClass;
    }

    /**
     * 构造方法
     *
     * @param userClass  用户类型
     * @param username   用户名
     * @param password   密码
     * @param rememberMe 记住我
     * @param host       主机
     */
    public UserAuthenticationToken(Class<?> userClass, String username, char[] password, boolean rememberMe, String host) {
        super(username, password, rememberMe, host);
        this.userClass = userClass;
    }

    /**
     * 获取用户类型
     *
     * @return 用户类型
     */
    public Class<?> getUserClass() {
        return userClass;
    }

    /**
     * 设置用户类型
     *
     * @param userClass 用户类型
     */
    public UserAuthenticationToken setUserClass(Class<?> userClass) {
        this.userClass = userClass;
        return this;
    }

    /**
     * 判断是否需要验证凭据
     *
     * @return 返回判断结果
     */
    public boolean isVerifyCredentials() {
        return isVerifyCredentials;
    }

    /**
     * 设置是否需要验证凭据
     *
     * @param verifyCredentials
     */
    public UserAuthenticationToken setVerifyCredentials(boolean verifyCredentials) {
        isVerifyCredentials = verifyCredentials;
        return this;
    }
}